#pragma GCC optimize(2)
#include <bits/stdc++.h>

using namespace std;
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3f;

void solve()
{
    int n, m, x;
    cin >> n >> m >> x;
    vector<bool> no(n + 1, false);
    for (int i = 0; i < x; i++)
    {
        int e;
        cin >> e;
        no[e] = true;
    }
    vector<vector<int>> grip(n + 1);
    for (int i = 0; i < m; i++)
    {
        int u, v;
        cin >> u >> v;
        grip[u].push_back(v);
        grip[v].push_back(u);
    }
    vector<bool> vis(n + 1, false);
    queue<int> q;
    q.push(1);
    vis[1] = true;
    while (q.size())
    {
        auto cur = q.front();
        q.pop();
        for (auto e : grip[cur])
        {
            if (!vis[e] && !no[e])
            {
                vis[e] = true;
                q.push(e);
            }
        }
    }
    vector<int> ans;
    for (int i = 1; i <= n; i++) if (vis[i]) ans.push_back(i);
    sort(ans.begin(), ans.end());
    for (int i = 0; i < ans.size(); i++) cout << ans[i] << ' ';
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int _ = 1;
    //cin >> _;
    while (_--)
    {
        solve();
    }
    return 0;
}